<%@page import="com.AO.DAO.*"%>
<%@page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=utf8"
    pageEncoding="utf8"%>
    <%MaterialFoodTypesDAO dao=new MaterialFoodTypesDAO();
    MaterialFoodTypes mfoodt=dao.findById((String)request.getAttribute("MFoodTypeid"));
    request.removeAttribute("MFoodTypeid"); %>
<!DOCTYPE html>
<!-- saved from url=(0040)foodfood/category/1304/ -->
<html  class=""><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  

    <title>素材种类</title>


    <link  href="./files/favicon.ico"  rel="shortcut icon"  type="image/x-icon">

<link  href="./files/base.d706c3c6.compress.css"  rel="stylesheet"  type="text/css">



<link  href="./files/other.0b3c792c.compress.css"  rel="stylesheet"  type="text/css">


<style  type="text/css"></style></head>



<body  style="">



<div  class="popup-layer">

  
  <div  class="reveal-modal-bg"></div>
  

  
<div  class="reveal-modal large normal-font"  id="feedbackModal">
  
  <div  class="reveal-modal-title-bar">
    <div  class="reveal-modal-title">意见反馈</div>
    <a  href="javascript:void(0)"  class="close-reveal-modal"  rel="nofollow"></a>
  </div>
  <div  class="reveal-modal-main">
    
    
    <form  action="foodfood/feedback/create/"  method="POST">
      <textarea  name="feedback"  rows="3"></textarea>
      <input  type="hidden"  name="xf"  value="None">
      <input  type="submit"  value="提交"  class="button">
    </form>
  
  
  </div>

</div>


</div>

<div  class="topbar-outer">
  <div  class="topbar-container">
    <div  class="topbar">
      



  <div  class="pure-g">
    <div  class="pure-u-1-6">
      <a  href="/foodfood/AOHomePage..action" class="logo"><img src="./files/logo.png"></a>
    </div>
    <div  class="pure-u-5-6">
      <div  class="pure-g">
        <div  class="pure-u-11-24">
         <form class="search" action="/foodfood/Search.action">
                                 <input type="text" name="keyword" class="typeahead float-left" data-default-text="" value="" placeholder="菜谱、食材">
                                 <input type="hidden" name="type" value="fmf">
                                 <input type="submit" value="搜索" class="button float-left">
                                </form>
        </div>
        <div  class="pure-u-1-3">
          <ul  class="site-nav plain pure-g">
            <li  class="pure-u"><a  href="/foodfood/AOHomePage..action"  data-ga-event="公共页面/导航栏/$text">首页</a></li>
            <li  class="topbar-cats pure-u">
            <a  href="/foodfood/AOMenu..action"  class="block-link"  data-ga-event="公共页面/导航栏/$text"><span>菜谱分类</span></a>
            <%MaterialFoodTypesDAO daoindex=new MaterialFoodTypesDAO();
									FoodTypesDAO daofindex=new FoodTypesDAO();
									List<MaterialFoodTypes>listindex=daoindex.findByMaterialFoodTypeLevel(1);
									List<FoodTypes>listfindex=daofindex.findByFoodTypeLevel(1); 
									MaterialFoodOfSeasonDAO dao5index=new MaterialFoodOfSeasonDAO();
									List<MaterialFoodOfSeason>list5index=dao5index.findAll();%>
										<div class="topbar-cats-submenu hidden">
											<div class="topbar-cats-submenu-bg">

												<ul class="plain">
													<li class="topbar-cat-head">常用主题</li>
													<% int k=0;for(FoodTypes ft:listfindex)
								                    {if(k++==8)break;%>
													<li><a
														href="/foodfood/AOFoodMenu.<%=ft.getFoodTypeId() %>.action"
														title="<%=ft.getFoodTypeName() %>菜谱大全" data-ga-event="公共页面/导航栏/$text"><%=ft.getFoodTypeName() %></a>
													</li>
													<%} %>
												</ul>
												<ul class="plain">
												   <li class="topbar-cat-head">常见食材</li>
												   <% k=0;for(MaterialFoodTypes ft:listindex)
								                    {if(k++==8)break;%>													
													<li><a href="/foodfood/AOMfoodMenu.<%=ft.getMaterialFoodTypeId() %>.action"
														title="<%=ft.getMaterialFoodTypeName() %>做法大全" data-ga-event="公共页面/导航栏/$text"><%=ft.getMaterialFoodTypeName() %></a>
													</li>
												   <%} %>
												</ul>
												<ul class="plain">
													<li class="topbar-cat-head">时令食材</li>
													<%k=0;for(MaterialFoodOfSeason mfos:list5index)						    
									               {if(k++==8)break;%>
													<li><a href="/foodfood/AOMfood.<%=mfos.getMaterialFood().getMaterialFoodId() %>.action"
														title="<%=mfos.getMaterialFood().getMaterialFoodName() %>做法大全" data-ga-event="公共页面/导航栏/$text"><%=mfos.getMaterialFood().getMaterialFoodName() %></a>
												   <%} %>
												</ul>
												<div class="topbar-cats-submenu-bottom">
													<a href="/foodfood/AOMenu..action"
														data-ga-event="公共页面/导航栏/$text">查看全部分类</a>
												</div>

											</div>
										</div>
            </li>
            <li  class="pure-u"><a  href="/foodfood/AOFoodInMenuList..action"  data-ga-event="公共页面/导航栏/$text">菜单</a></li>
          </ul>
        </div>
        <div  class="pure-u-5-24 clearfix">

          <div  class="user-action">
              	<div class="user-action">
		              <%
							String account = (String)session.getAttribute("account");
							String nickname = (String)session.getAttribute("nickname");
						    	
			              	if(nickname!=null)
			           		{
						%>
						<a href="/foodfood/AOCooker.<%=account%>.action"><%=nickname%></a>
						<a onclick="logout()" href="index.jsp">退出</a>
						<%
							}
			               	else
			               	{
						%>
						<a href="register.jsp" data-ga-event="公共页面/导航栏/$text">注册</a> <a
							href="login.jsp" data-ga-event="公共页面/导航栏/$text">登录</a>&nbsp;&nbsp;
						<%
							}
						%>
		
		          </div>
          </div>
        </div>
      </div>
    </div>
  </div>


    </div>
  </div>
</div>


<div  class="page-outer">
  
  <div  class="page-container">
    
      <div  class="pure-g">
        
        <div  class="pure-u-2-3 main-panel">
          

<div  class="white-bg block">
  <div  class="pure-g">
    <div  class="pure-u-1-4 category-left-nav">
      

      <div  class="category-left-tree gray-font">
        
        <ul  class="plain list level1">
        <%
        for(MaterialFoodTypes ft:daoindex.findByMaterialFoodTypeLevel(2) )
        {boolean tag=false;%>
        <%for(MfoodMfoodTypesRelation mmtr:ft.getMfoodMfoodTypesRelations()){%>
        <%if(mmtr.getMaterialFood().getMaterialFoodId().equals(""))
        {out.print(" <li  class=\"open\">");tag=true;break;}
         }if(!tag){out.print(" <li  class>");} %>
              <p  class="name"><%=ft.getMaterialFoodTypeName() %></p>
            <%if(!tag){out.print("<ul  class=\"level2 plain list hidden\">");} else{out.print("<ul  class=\"level2 plain list \">");}%>
             <%for(MfoodMfoodTypesRelation mmtr:ft.getMfoodMfoodTypesRelations()){
              if(mmtr.getMaterialFood().getMaterialFoodId().equals(""))
              {out.print(" <li  class=\"active\">");}else{out.print(" <li  class=\"\">");}%>
                <a  href="/foodfood/AOMfood.<%=mmtr.getMaterialFood().getMaterialFoodId() %>.action"><%=mmtr.getMaterialFood().getMaterialFoodName() %>
                  <span  class="green-font">
                  </span>
                </a>
              </li>
              <%} %>
            </ul>
          </li>
          <%} %>
        </ul>
      </div>
      
    </div>
   
   
   
    
    <div  class="pure-u-3-4 category-recipe-list">
      

<div  class="pure-g">
  <div  class="pure-u ing-cover align-middle">
    <img  src="<%=mfoodt.getImg() %>"  alt="<%=mfoodt.getMaterialFoodTypeName() %>"  width="120"  height="120">
  </div>
  <div  class="pure-u align-middle">
    <div  class="ing-title-text">
      <h1  class="page-title mb0"><%=mfoodt.getMaterialFoodTypeName() %></h1>
      <div><a  href="http://www.baike.baidu.com/search/word?word=<%=mfoodt.getMaterialFoodTypeName() %>"  class="gray-link small-font"  target="_blank"  rel="nofollow">去百度百科了解食材 &gt;</a></div>
    </div>
  </div>
</div>

<ul  class="ing-tab tab plain">
  <li  class="active">相关菜谱</li>
</ul>
</div>  
        <img  src="./files/e6acdd56ee0e11e4b77cb8ca3aeed2d7.jpg"  class="hidden">
        
<div  class="normal-recipe-list">
    <ul  class="list">
    <%
    Set<Food> set=new HashSet<Food>();
    Set<MfoodMfoodTypesRelation>setm=new HashSet<MfoodMfoodTypesRelation>();
    if(mfoodt.getMaterialFoodTypeLevel()==2)
    {
       for(MfoodMfoodTypesRelation mmtr:mfoodt.getMfoodMfoodTypesRelations())
       {
          for(FoodMaterialFoodRelation fmfr:mmtr.getMaterialFood().getFoodMaterialFoodRelations())
          {
            if(fmfr.getMaterialFoodLevel()==1)
            {
                set.add(fmfr.getFood());
            }
          }
       }
    }
    else
    {
       for(MaterialFoodTypes mft:mfoodt.getMaterialFoodTypeses())
       {
            setm.addAll(mft.getMfoodMfoodTypesRelations());           
       }
       for(MfoodMfoodTypesRelation mmtr:setm)
       {
          for(FoodMaterialFoodRelation fmfr:mmtr.getMaterialFood().getFoodMaterialFoodRelations())
          {
            if(fmfr.getMaterialFoodLevel()==1)
            {
                set.add(fmfr.getFood());
            }
          }
       }
    }
    int i=0;
    int each=4;
   int size=set.size()/each;
   if(set.size()%each!=0)
    size++;
    for(Food food:set)
    {
          if(i/each!=0)
      {
     %>
     <li class="showfood<%=(i++/each)+1 %>" style="display:none">
     <%}else{ %>
  <li class="showfood<%=(i++/each)+1 %>">
    <%} %>
        
<div  class="recipe-140-horizontal pure-g">
    <div  class="cover pure-u">
        <a  href="/foodfood/AOFood.<%=food.getFoodId()%>.action"  class="image-link">
            <img  src="<%=food.getImg() %>"  data-src="<%=food.getImg()%>"  width="140"  height="106"  alt="<%=food.getFoodName() %>"  class="unveiled">
        </a>
    </div>
    <div  class="info pure-u">
        <p  class="name">
            <a  href="/foodfood/AOFood.<%=food.getFoodId()%>.action" ><%=food.getFoodName() %></a>

            <i  class="step-icon"></i>
        </p>
        <p  class="ing ellipsis">
            <%Set<FoodMaterialFoodRelation> set2=food.getFoodMaterialFoodRelations();
              String mflist="";
              for(FoodMaterialFoodRelation fmfr2:set2)
              {
                  mflist+=fmfr2.getMaterialFood().getMaterialFoodName()+"|";
              }
                int eachline=22;
                int j=mflist.length()/eachline;
                if(mflist.length()%eachline!=0)
                 j++;
                 for(int lines=0;lines<j;lines++)
                 {
                    if((lines+1)*eachline<mflist.length())
                       out.print(mflist.substring(lines*eachline,(lines+1)*eachline)+"<br>");
                    else
                     out.print(mflist.substring(lines*eachline,mflist.length()-1)+"<br>");
                 }
                         String str=food.getEvaluation();
               String[] lists=str.split(",");
               double good=Double.parseDouble(lists[0]);
               double simple=Double.parseDouble(lists[1]);
               double bad=Double.parseDouble(lists[2]);
               double total=good+simple+bad;
               double percentsG=1;
               double percentsS=1;
               double percentsB=1;
               double grade=0;
               if(total!=0)
               {
                    percentsG=good/total;
                    percentsS=simple/total;
                    percentsB=bad/total;
                    grade=(40+60*percentsG+40*percentsS+30*percentsB);
                    grade=(double)((int)(grade*10))/10;
               }
               %>
        </p>
        <p  class="stats">
                综合评分&nbsp;<span  class="score bold green-font"><%=grade %></span>
        </p>
        <p  class="author">
                <a  href="/foodfood/AOUser.<%=food.getUser().getAccount()%>.action"  class="gray-link"><%=food.getUser().getNickName() %></a>
        </p>
    </div>
</div>

        </li>
    <%} %> 
    </ul>
      <div  class="pager">
       <a id="pre" name="1" href="javascript:void(0)" onclick="toggle(this)">上一页</a><%for(i=0;i<size;i++){ if(i==0){%>
       <a name="<%=i+1 %>" href="javascript:void(0)" onclick="toggle(this)" class="now">
       <%}else{ %>
       <a name="<%=i+1 %>" href="javascript:void(0)" onclick="toggle(this)">
       <%} %>
       <%=i+1 %></a><%} %><a id="next" href="javascript:void(0)" name="1" onclick="toggle(this)">下一页</a>
  </div>
</div>

    </div>
  </div>
</div>

          <div  id="main-panel-bottom"></div>
        </div>
        

        
        <div  class="pure-u-1-3 right-panel">
          

  

        </div>
        
      </div>
    
  </div>
  
</div>

<div  class="bottom-outer">
  <div  class="bottom-container">
   
  </div>
</div>




  
  <script  type="text/javascript"  src="./files/jquery.min.js"></script>
 
<script  type="text/javascript"  src="./files/2013.anonymous.0a0601dc.compress.js"></script><img  id="scrollTop"  src="./files/scroll_top.png"  style="opacity: 1; position: fixed; width: 50px; height: auto; z-index: 20; border: 0px; padding: 0px; bottom: 20px; right: 20px; margin: 0px; cursor: pointer; display: none;">


<div  id="color_timer"></div>





</body>
<script type="text/javascript">
    function toggle(t)
    {
       clickA=$(t);
       if(clickA.attr("id")=="next")
       {
          if($(".pager a[name="+(clickA.attr("name"))+"]").next().length!=0)
          {
              $(".pager a[name="+(parseInt(clickA.attr("name"))+1)+"]").click();
          }
       }
       else if(clickA.attr("id")=="pre")
       {
          if($(".pager a[name="+(clickA.attr("name"))+"]").prev().length!=0)
          {
              $(".pager a[name="+(parseInt(clickA.attr("name"))-1)+"]").click();
          }
       }
       else
       {
       clickA.attr("class","now");
       clickA.siblings().attr("class","");
       $(".showfood"+clickA.attr("name")).css("display","block");
       for(i=0;i<<%=size %>;i++)
       {
          if(i+1!=clickA.attr("name"))
            $(".showfood"+(i+1)).css("display","none");
       }
       $("#pre").attr("name",clickA.attr("name"));
       $("#next").attr("name",clickA.attr("name"));
       }
    }

</script>
</html>
